package globals;

import game.Universe;
import graphics.GraphicalObject;
import graphics.Meshes.MeshObject;
import graphics.ParticleSystem.Explosion;
import graphics.ParticleSystem.PlanetParticleSystem;
import graphics.ParticleSystem.VolcanoParticleSystem;
import graphics.Shapes.Box;
import graphics.Shapes.GraphicalObjectNoLight;
import graphics.Shapes.Sphere;
import physics.Avatar;
import physics.Bomb;
import physics.Carrot;
import physics.GameObject;
import physics.GiantRobot;
import physics.Grenade;
import physics.Knife;
import physics.LavaSphere;
import physics.Missile;
import physics.Planet;
import physics.PortalEntrance;
import physics.PortalExit;
import physics.Robot;
import physics.Sun;
import viewControllers.CarrotViewController;
import viewControllers.GrenadeViewController;
import viewControllers.KnifeViewController;
import viewControllers.MessileViewController;
import viewControllers.ViewController;
import viewControllers.robot.BunnyViewController;
import viewControllers.robot.RobotViewController;

public class ObjectFactory { 
	
	public ObjectFactory(){}
	
	public static GameObject createGameObject(ObjectType type){
		GameObject newObject = null;
		switch (type){
		case AVATAR:
			newObject = createGameObject(ObjectType.AVATAR, 0.6, 3);
			break;
		case PLANET:
			newObject =  new Planet();
			break;
		case SUN:
			newObject =  new Sun();
			break;
		
		case BOMB:
			newObject =  new Bomb();
			break;
			
		case CARROT:
			newObject = createGameObject(ObjectType.CARROT, 0.1, 1);
			break;

		case GRENADE:
			newObject = createGameObject(ObjectType.GRENADE, 0.1, 1);
			break;


		case ROBOT:
			newObject = createGameObject(ObjectType.ROBOT, 3, 3);
			break;
		
		case GIANTROBOT:
			newObject = createGameObject(ObjectType.GIANTROBOT, 3, 8);
			break;
		
		case GIANTCARROT:
			newObject = createGameObject(ObjectType.CARROT, 0.4, 3);
			newObject.setName("theOne");
			break;
			
		case KNIFE:
			newObject = createGameObject(ObjectType.KNIFE, 0.3, 2);
			break;
			
		case MISSILE:
			newObject = createGameObject(ObjectType.MISSILE, 4.5, 0.5);
			break;
		
			
		case PORTAL:
			newObject =  new PortalEntrance();
			break;
			
		case EXIT:
			newObject =  new PortalExit();
			break;		
		
		case LAVAPLANET:
			newObject =  new LavaSphere();
			break;		
		
		
		case DEFAULT:
			newObject =  new GameObject();
			break;
		}
		
		
		
		return newObject;
	}

	
	private static GameObject createGameObject(ObjectType type, double radius,double scale){
		GameObject newObject = null;
		ViewController VC = null;
		switch (type){
			case CARROT:
				newObject =  new Carrot();
				VC = new CarrotViewController(newObject);
				break;

			case ROBOT:
				newObject =  new Robot();
				VC = new RobotViewController(newObject);
				break;

			case AVATAR:
				newObject =  new Avatar();
				VC = new BunnyViewController(newObject);
				break;
		
			case GIANTROBOT:
				newObject =  new GiantRobot();
				VC = new RobotViewController(newObject);
				break;
		
		
			case KNIFE:
				newObject =  new Knife();		
				VC = new KnifeViewController(newObject);
				break;
				
			case GRENADE:
				newObject =  new Grenade();		
				VC = new GrenadeViewController(newObject);
				break;
			
			case MISSILE:
				newObject =  new Missile();		
				VC = new MessileViewController(newObject);
				break;
				
		
		}	
			
		if (scale != 0)
			VC.setScale(scale);
		if (radius != 0)
			newObject.setRadius(radius);
		newObject.setGraphicalObject(VC);
		Universe.addGameObject(newObject);
		return newObject;	
	}
	
	
	public static GraphicalObject createGraphicalObject(GraphicalObjectType type){
		GraphicalObject newObject = null;
		switch (type){

		case MESH:
			newObject =  new MeshObject();
			break;
		case SPHERE:
			newObject =  new Sphere();
			break;	
		case BOX:
			newObject =  new Box();
			break;	
			
		case VOLCANO:
			newObject =  new VolcanoParticleSystem();
			break;	
			
		case NOLIGHT:
			newObject =  new GraphicalObjectNoLight();
			break;
		
		case LAVAFIRE:
			newObject =  new PlanetParticleSystem();
			break;
			
		case EXPLOSION:
			newObject =  new Explosion();
			break;	
			
			
		case BOMB:
//			newObject =  new Bomb();
			break;
		case CARROT:
//			newObject =  new Carrot();
			break;
		case PORTAL:
//			newObject =  new PortalViewController();
			break;
		case DEFAULT:
//			newObject =  new GameObject();
			break;
		}
		
		return newObject;
	}
}
